//
//  InfosGetter.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/20.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class InfosGetter: NSObject {
    class func infos(source : Dictionary<String,String>)->Array<Dictionary<String,String>>{
        var array : Array<Dictionary<String,String>> = []
        var screen_displayDic : Dictionary<String,String> = ["title":"内屏显示"]
        if let screen_display = source["screen_show"] {
            if screen_display == "0" {
                screen_displayDic["content"] = "屏幕正常显示"
            } else if screen_display == "1" {
                screen_displayDic["content"] = "有坏点/亮点/色差"
            } else if screen_display == "2" {
                screen_displayDic["content"] = "严重老化/漏液/错乱"
            } else if screen_display == "3" {
                screen_displayDic["content"] = "内屏进水"
            } else if screen_display == "12" {
                screen_displayDic["content"] = "有坏点/亮点/色差\n严重老化/漏液/错乱"
            } else if screen_display == "13" {
                screen_displayDic["content"] = "有坏点/亮点/色差\n内屏进水"
            } else if screen_display == "23" {
                screen_displayDic["content"] = "严重老化/漏液/错乱\n内屏进水"
            } else if screen_display == "123" {
                screen_displayDic["content"] = "有坏点/亮点/色差\n严重老化/漏液/错乱\n内屏进水"
            }
        } else {
            screen_displayDic["content"] =  "屏幕显示不正常"
        }
        array.append(screen_displayDic)
        
        var touch_dic : Dictionary<String,String > = ["title":"触屏"]
        if let touch_error = source["touch_error"] {
            if touch_error == "1" {
                touch_dic["content"] = "触屏正常"
            } else if touch_error == "0" {
                touch_dic["content"] = "触屏不正常"
            }
        } else {
            touch_dic["content"] = "触屏不正常"
        }
        array.append(touch_dic)
        
        var channelDic = ["title":"具体型号"]
        if let channel = source["channel"] {
            channelDic["content"] = channel
            array.append(channelDic)
        } else {
            channelDic["content"] = ""
        }
        
        var border_dic = ["title":"边框外壳"]
        if let border_shell = source["border_shell"] {
            if border_shell == "0" {
                border_dic["content"] = "边框有瑕疵"
            } else if border_shell == "1" {
                border_dic["content"] = "边框无瑕疵"
            }
        } else {
            border_dic["content"] = "边框有瑕疵"
        }
        array.append(border_dic)
        
        var screen_appearDic = ["title":"屏幕外观"]
        if let screen_appearance = source["screen_appearance"] {
            if screen_appearance == "0" {
                screen_appearDic["content"] = "外观有瑕疵"
            } else if screen_appearance == "1" {
                screen_appearDic["content"] = "外观无瑕疵"
            }
        } else {
            screen_appearDic["content"] = "外观有瑕疵"
        }
        array.append(screen_appearDic)
        var maintanceDic : Dictionary<String,String> = ["title":"维修史"]
        if let maintance = source["maintenance"] {
            if maintance == "1" {
                maintanceDic["content"] = "有维修"
            } else if maintance == "0" {
                maintanceDic["content"] = "无维修"
            }
        } else {
            maintanceDic["content"] = "有维修"
        }
        array.append(maintanceDic)
        
        var problemsDic = ["title":"其他问题"]
        if let problems = source["problems"] {
            if problems.characters.count == 0 {
                 problemsDic["content"] = "无"
            } else {
                problemsDic["content"] = problems
                array.append(problemsDic)
            }
        } else {
            problemsDic["content"] = "无"
        }
        return array
    }
}
